
//展示用户名
function showUser(){

    $.ajax({
        url: "/showUser",
        type: "get",
        dataType: "json",
        data: {},
        async: true,
        success: function (result) {
            if (result.code) {
                var json2map = JSON.parse(result.data);

                //layer.alert(result.msg, "title");
                $("#nickname").html(json2map.nickname);
            } else {
                layer.msg(result.msg, {icon: 5,time:2000}, function(){
                    location.href = "http://" + window.location.host;
                });
            }
        },
        error: function () {
            layer.alert("系统繁忙,请稍后");
        }
    });
}
showUser();

//加载目录
function loadMenu() {
    $.ajax({
        url: "/menu/queryMenu",
        type: "get",
        dataType: "json",
        data: {},
        async: true,
        success: function (result) {
            console.log(result.data[0]);

            if (result.code) {
                var data = result.data[0];
                var childrenLength = data.children.length;


            } else {
                layer.msg(result.msg, {icon: 5,time:2000}, function(){
                    layer.alert("目录加载失败！", "title");
                });
            }
        },
        error: function () {
            layer.alert("系统繁忙,请稍后");
        }
    });
}
loadMenu()